<?

/**
 * Start e Stop um contador interno em microsegundos
 */
class Qi_Profiler_Timer
{
	public $avg = null;
	private $last_time = 0;

	public function __construct($auto_start = true)
	{
		$this->avg = new Qi_Profiler_Avg();
		if ($auto_start) $this->start();
	}

	public function start()
	{
		$this->last_time = microtime(true);
	}

	public function stop()
	{
		$time = microtime(true);
		$duracao = $time - $this->last_time;
		$this->avg->append($duracao);
	}
}

?>